Hi, I’m Olga! I have years of experience in data science, most recently at eBay and now I work as an industry mentor at Pathrise, helping data scientists land a great role through technical workshops and 1-on-1s. Check out my list of Python interview questions.
Python is one of the most well known programming languages and it is used by many companies and teams. It has become one of the most common languages for data science. So, if you are looking for data roles, it is important to practice the Python interview questions you will be asked.
We have worked with many data scientists and software engineers with data backgrounds on their job search and a lot of our time goes into technical interview preparation, so we created this list of 58 Python interview questions from real tech companies and tips to keep in mind when you go into the interview.
- Infosys question – How do you set a global variable in a function?
- Google question – How do I share global variables across modules?
- Facebook question – What is a class?
- Spotify question – How do I avoid blocking in the connect() method of a socket?
- Infosys question – How do I generate random numbers in Python?
- Netflix question – How do I emulate os.kill() in Windows?
- Infosys question – How can I find the methods or attributes of an object?
- Accenture question – What is PEP 8?
- Dropbox question – What are Python literals?
- CA Technologies – What is a zip() function in Python?
- Autodesk question – What is Python’s parameter passing mechanism?
- Uber question – How do you overload constructors or methods in Python?
- Slack question – What is the difference between a remove() function and del statement?
- Accenture question – What is a swapcase() function in Python?
- Facebook question – Why do we use join() function in Python?
- Google question – Give an example of shuffle() method?
- Spotify question – What is the use of a break statement?
- Netflix question – What is a tuple in Python?
- Accenture question – Which are the file related libraries/modules in Python?
- Autodesk question – What are the different file processing modes supported by Python?
- Facebook question – How do you find bugs or perform static analysis in a Python application?
- CA Technologies – When is the Python decorator used?
- Uber question – What is the key difference between a list and tuple?
- Dropbox question – How does Python handle memory management?
- Slack question – How do you remove whitespaces from a string in Python?
- Spotify question – What is NumPy and how is it better than a List in Python?
- Google question – What are the different ways to create an empty NumPy array in Python?
- Facebook question – What are different ways to create an empty array in Python?
- Accenture question – What are the ways to write a function using call by reference?
- What is the output of print tuple if tuple = (‘abcd’, 786 , 2.23, ‘john’, 70.2)?
- Netflix question – What is the output of print tuple[0] if tuple = (‘abcd’, 786 , 2.23, ‘john’, 70.2)?
- Autodesk question – How would you convert a string to all lowercase?
- Slack question – What are the built-in types available in Python?
- Dropbox question – How would you convert a string to a long in Python? What about a string to a float, object, list, and set?
- CA Technologies – How would you convert an object to a string in Python? What about an object to a regular expression?
- Google question – What are the principal differences between the lambda and def?
- Spotify question – Write a reg expression that confirms an email ID using the Python reg expression module
? - Slack question – Is there a switch or case statement in Python?
- Autodesk question – What is a built-in function that Python uses to iterate over a number sequence?
- Uber question – What are the optional statements that can be used inside a
block in Python? - Facebook question – What is the output of L[1:] if L = [1,2,3]?
- CA Technologies – How would you get the max valued item of a list? How would you get the min valued item of a list?
- Autodesk question – How does the ternary operator work in Python?
- Spotify question – What does the
keyword do? - Netflix question – What are the different methods to copy an object in Python?
- Uber question – What is the purpose of DocStrings in Python?
- CA Technologies – Is Python a case sensitive language?
- Dropbox question – What programming paradigm does Python support?
- Google question – How would you take input from the user in Python?
- Spotify question – What is the output of print str * 2 if str = ‘Hello World!’?
- Autodesk question – What is the output of print str + “TEST” if str = ‘Hello World!’?
- Facebook question – How do you terminate a line of code in Python?
- CA Technologies – How is global value mutation used for thread-safety?
- Slack question – How would you compare 2 lists? How would you get the length of a list?
- Dropbox question – Write a program to read and write the binary data using Python
- Netflix question – What is the output of print tuple[1:3] if tuple = ( ‘abcd’, 786 , 2.23, ‘john’, 70.2 )?
- Google question – What is the output of print tuple[2:] if tuple = ( ‘abcd’, 786 , 2.23, ‘john’, 70.2 )?
- CA Technologies – What is the purpose of // operator?
Don’t forget – there is more to a successful interview than just answering the questions correctly. Interviewers are looking to make sure you understand what you are doing and that you have the soft skills necessary to be an asset in the role. Use these tips to help you as you work through the challenges in your sessions.
- Start with clarifying questions
The question they give you can probably be interpreted in a few different ways, so read it through carefully and then come up with a few clarifying questions to ask before you begin working. Some examples are: “Are repetitions allowed?” or “Do you want to return permutations or combinations?”
- Be proactive in your interview
While you go through your problem, provide tidbits of knowledge to your interviewer so they understand what you know without having to ask you directly. This creates a more conversational feeling and minimizes the number of potentially awkward silences, especially in moments where you are thinking and not coding.
- Provide context and reasoning
You should also be giving the interviewer reasons for your decisions, so that can understand what is going through your mind as you work. Walking them through your thought process and choices will help them get a sense of your mindset, which is especially important if you make a mistake, because they will understand where you went wrong.
- Get guidance through collaboration
Some interviewers really hate the word “hint” but you can ask for, and receive, support in a different way. If you find yourself struggling at a certain point, make a collaborative statement to the interviewer like “my assumptions are X and Y, I’m thinking of doing Z. But I’m struggling with solving [problem].” You can also try asking questions or making comments like,
- I was wondering if you had any thoughts.
- Do you think I’m going down the right direction?
- Do you think my assumptions are incorrect?
With these Python interview questions & tips in your back pocket, you should be more than prepared for your next technical onsite interview. Feel like you need more help? Check out these resources to practice more software engineering interview questions. You can also check out our other interview question lists:
- Java interview questions from top tech companies
- C# interview questions from top tech companies
- Javascript interview questions from top tech companies
- C interview questions from top tech companies
- Software engineer interview questions from top tech companies
- Data science interview questions from top tech companies
Pathrise is a career accelerator that works with students and professionals 1-on-1 so they can land their dream job in tech. With these tips and guidance, fellows have seen their interview scores double.
If you want to work with any of our mentors 1-on-1 to get help with your software engineer interviews or with any other aspect of the job search, become a Pathrise fellow.